package com.amt.iptvsetting.arouter.interceptor;

import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.os.Looper;
import android.util.Log;
import android.widget.Toast;

import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.facade.annotation.Interceptor;
import com.alibaba.android.arouter.facade.callback.InterceptorCallback;
import com.alibaba.android.arouter.facade.template.IInterceptor;
import com.app.common.CommonManagerKt;

@Interceptor(priority = 0, name = "common")
public class CommonInterceptor implements IInterceptor {

    private static final String TAG = CommonInterceptor.class.getSimpleName();
    private Context context;
    @Override
    public void process(Postcard postcard, InterceptorCallback callback) {
        Log.i(TAG, "process: ");
        String action = postcard.getAction();

        Uri uri = postcard.getUri();

        Log.i(TAG, "process: action -> " + action + "::uri -> " + uri);
        String path = postcard.getPath();
        Log.i(TAG, "process: path -> " + path);

        if ("/zhouwd/virtual_apk_activity".equals(path)) {
            Bundle bundle = postcard.getExtras();
            Log.i(TAG, "process: bundle -> " + bundle);
            bundle.putString("result", "存在Gradle插件版本问题");
            postcard.with(bundle);
            callback.onInterrupt(null);
        } else if ("/z_media/z_camera_activity1".equals(path)) {
            Bundle bundle = postcard.getExtras();
            Log.i(TAG, "process: bundle -> " + bundle);
            bundle.putString("result", "未完善，完善中。。。。");
            postcard.with(bundle);
            callback.onInterrupt(null);
        } else {
            callback.onContinue(postcard);
        }
    }

    @Override
    public void init(Context context) {
        Log.i(TAG, "init: ");
        this.context = context;
    }
}
